def liux():
    global r,x,y,o,g,t,h,t,m,cuowu,cuo
    import time,random
    r = 0
    x = 0
    y = 0
    o = 0
    g = 4   #告诉程序一共听写几次
    m = 0
    cuo = 0
    t = {}
    h = {}
    t = {}
    cuowu = {}
    yi = {'更年轻的':'younger','更年长的':'older','更高的':'taller','更短的':'shorter','更长的':'longer','更瘦的':'thinner','更重的':'heavier','更大的':'bigger','更小的':'smaller','更强壮的':'stronger','恐龙':'dinosaur','大厅':'hall','英式米':'metre','美式米':'meter','比':'than','两个都':'both','千克':'kilogram','乡村':'countryside','更低':'lower','影子':'shadow','更聪明的':'smarter','开始变得；变成':'become'}
    er = {'打扫':'cleaned','待':'stayed','洗':'washed','看（电视）':'watched','得病':'had','感冒':'had a cold','睡觉':'slept','读':'read','看':'saw','最近的；上一个的':'last','昨天':'yesterday','在……之前':'before','喝':'drank','演出':'show','杂志':'magazine','更好的':'better','更快的':'faster','旅馆':'hotel','修理':'fixed','破损的':'broken','台灯':'lamp','大声的':'loud','享受……的乐趣':'enjoy','暂住':'stay'}
    san = {'去':'went','野营':'camp','去野营':'went camping','钓鱼':'fish','去钓鱼':'went fishing','骑':'rode','受伤':'hurt','吃':'ate','拍照':'took','照相':'took pictures','买':'bought','礼物':'gift','摔倒':'fell','落下':'off','劳动节':'Labour Day','骡子':'mule','吐鲁番':'Turpan','能':'could','直到':'till','沙滩':'beach','篮子':'basket','角色':'part','舔':'licked','笑':'laughed'}
    si = {'dining hall':'饭厅','grass':'草坪','gym':'体育馆','ago':'以前','cycling':'骑自行车运动（或活动）','go cycling':'去骑自行车','ice-skate':'滑冰','badminton':'羽毛球运动','star':'星','easy':'简单的','look up':'查阅（在词典中或通过电脑）','Internet':'互联网','different':'不同的','active':'积极的；活跃的','race':'赛跑','nothing':'没有什么','thought':'想（think的过去式）','felt':'感觉（feel的过去式）','cheetah':'猎豹','trip':'绊倒','woke':'醒（wake的过去式）','dream':'梦'}
    e = {0:yi,1:er,2:san,3:si}
    def q(v):
        global r,x,y,o,g,t,h,t,m,cuowu,cuo
        dict_key_ls = list(v.keys())
        random.shuffle(dict_key_ls)
        new_dic = {}
        for key in dict_key_ls:
            new_dic[key] = v.get(key)
        v = new_dic
        if '打扫' in v or '去' in v:
            print('提示：本单元所有动词都是过去式形式！\n')
        for i in v:
            if v == si:
                cuowu = v[i]
                q = input(cuowu + '：')
                w = i
            else:
                cuowu = i
                w = v[i]
                q = input(cuowu + '：')
            if q == w:
                print('对喽！')
                r += 1
            else:
                print('错啦错啦！')
                t[cuowu] = w
                x += 1
        print('结束！')
        print('一共对',r,'道，错',x,'道')
        if x != 0:
            cuo += 1
            print('\n不扎实',x,'道！巩固错题：')
            x = 0
            for i in t:
                q = input(i + '：')
                w = t[i]
                if q == w:
                    print('对喽！')
                    y += 1
                else:
                    print('错啦错啦！')
                    o += 1
                    m += 1
                    x += 1
                    h[i] = w
            print('结束！')
            print('一共对',y,'道，错',o,'道')
        r = 0
        c = 0
        y = 0
        o = 0
        x = 0
        t = {}
    for l in range(g):
        print('\n第',l+1,'单元！\n')
        v = e[l]
        q(v)
    if m != 0:
        html = open('cuowu.txt','a')
        html.close()
        html = open('cuowu.txt','r')
        php = html.read()
        html.close()
        go = open('cuowu.txt','a')
        print('\n错题答案：共',m,'个二错单词\n')
        for i in h:
            d = h[i]
            print(i , d)
            if i not in php or d not in php:
                go.write("'")
                go.write(i)
                go.write("'")
                go.write(':')
                go.write("'")
                go.write(d)
                go.write("'")
                go.write(',\n')
    time.sleep(10)
